package com.lifeverse.entity.enums;

/**
 * 审计结果枚举
 * 定义操作的执行结果
 */
public enum AuditResult {
    
    /**
     * 成功
     */
    SUCCESS("成功"),
    
    /**
     * 失败
     */
    FAILURE("失败"),
    
    /**
     * 部分成功
     */
    PARTIAL_SUCCESS("部分成功"),
    
    /**
     * 被拒绝
     */
    DENIED("被拒绝"),
    
    /**
     * 超时
     */
    TIMEOUT("超时"),
    
    /**
     * 取消
     */
    CANCELLED("取消"),
    
    /**
     * 未知
     */
    UNKNOWN("未知");
    
    private final String description;
    
    AuditResult(String description) {
        this.description = description;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 判断是否为成功结果
     */
    public boolean isSuccess() {
        return this == SUCCESS || this == PARTIAL_SUCCESS;
    }
    
    /**
     * 判断是否为失败结果
     */
    public boolean isFailure() {
        return this == FAILURE || this == DENIED || this == TIMEOUT;
    }
    
    /**
     * 判断是否需要告警
     */
    public boolean needsAlert() {
        return this == FAILURE || this == DENIED || this == TIMEOUT;
    }
}